
***Note: replicators should set directory to open data 
*cd ""

*Also note data are in .sav format, need to be put in stata

********** FIGURE 2g: Gender Attitudes, United states **********

*Based on US data from General Social Survey, see appendix. Original dataset: https://gss.norc.org/


clear all
use "GSS.dta", clear


gen midwest = 0
replace midwest = 1 if region == 4 | region == 3 | region == 2

gen northeast = 0
replace northeast = 1 if region == 1  

gen south = 0
replace south = 1 if region == 5 | region == 7 | region == 6

gen west = 0
replace west = 1 if region == 8 | region == 9

gen Area=.
replace Area=1 if midwest==1
replace Area=2 if northeast==1
replace Area=3 if south==1
replace Area=4 if west==1
 

label variable Area "Subcontinent"
la def aria  1 "Midwest" 2 "Northeast" 3 "South" 4 "West", modify
la val Area aria


   grstyle init
 grstyle set legend 2,  nobox
 grstyle set size 8pt: tick_label key_label
 grstyle set size 12pt: heading
 grstyle set size 10pt: subheading axis_title 
 grstyle set graphsize 13cm 11.5cm
 

reg    PD D
ereturn list
loc N6= e(N)
local b= round(_b[D],.001) 
local t = _b[D]/_se[D]  
local p =round(2*ttail(e(df_r),abs(`t')),.001)  


graph twoway    (lfitci PD  D,   lcol(black)  lwidth(medthick) ciplot(rline) blpattern(dash) acolor(black%65))  (scatter PD  D if Area==1, mcolor(black)   msymbol(d))   (scatter PD  D if Area==2,   mcolor(black)    msymbol(S)) (scatter PD  D if Area==3,   mcolor(black)   msymbol(o)) (scatter PD  D if Area==4,   mcolor(black)    msymbol(T)) ,  legend(position(12) rows(1)  order(3 "Midwest" 4 "Northeast" 5 "South" 6 "West") span) ytitle("Perceptions of discrimination")    xtitle("Discriminatory attitudes")  note("Author's computation based on GSS." "Plot region-round pairwise correlation. {&rho} = `b' | {it:p-value} = `p' | {it:N} = `N6'." ,size(vsmall) span) subtitle("{bf: Gender attitudes in the United States}") 
graph export "Graph/Figure2h.tif", replace 
graph save "Graph/Figure2h", replace


